<?php
/**
Template Name: Blog
*
* This template is used to display a blog. The content is displayed in post formats.
*
* @package vn.news
* @since vn.news 1.0
*
*/
get_header(); ?>

<!-- BEGIN .post class -->
<div <?php post_class(); ?> id="page-<?php the_ID(); ?>">

	<?php if ( has_post_thumbnail()) { ?>
		<div class="feature-img banner shadow radius-full"><?php the_post_thumbnail( 'featured-large' ); ?></div>
	<?php } ?>

	<!-- BEGIN .row -->
	<div class="row">

	<?php if ( is_active_sidebar( 'blog-sidebar' ) ) : ?>

		<!-- BEGIN .eleven columns -->
		<div class="eleven columns">

			<!-- BEGIN .postarea -->
			<div class="postarea">
			<?php
	        	$args = array("post_type"=>"post", "post_status"=>"publish", "ignore_sticky_posts" => 1, 'paged' => $paged);

	        	$my_query = new WP_Query($args);
	        	$num_page = $my_query->max_num_pages;
				while ($my_query->have_posts()) : $my_query->the_post(); ?>
					<!-- BEGIN .blog-holder -->
					<div class="blog-holder">

						<?php get_template_part( 'loop', 'blog' ); ?>

					<!-- END .blog-holder -->
					</div>

				<?php endwhile; ?>

				<!-- BEGIN .pagination -->
				<div class="pagination">
					<?php echo vnnews_get_pagination_links_2($num_page); ?>
				<!-- END .pagination -->
				</div>

			<?php WP_Reset_Query(); ?>

			<!-- END .postarea -->
			</div>

		<!-- END .eleven columns -->
		</div>

		<!-- BEGIN .five columns -->
		<div class="five columns">

			<?php get_sidebar('blog'); ?>

		<!-- END .five columns -->
		</div>

	<?php else : ?>

		<!-- BEGIN .sixteen columns -->
		<div class="sixteen columns">

			<!-- BEGIN .postarea full -->
			<div class="postarea full">

			<?php
	        	$args = array("post_type"=>"post", "post_status"=>"publish", "ignore_sticky_posts" => 1, 'paged' => $paged);

	        	$my_query = new WP_Query($args);

				while ($my_query->have_posts()) : $my_query->the_post(); ?>

					<!-- BEGIN .blog-holder -->
					<div class="blog-holder">

						<?php get_template_part( 'loop', 'blog' ); ?>

					<!-- END .blog-holder -->
					</div>

				<?php endwhile; ?>

				<!-- BEGIN .pagination -->
				<div class="pagination">
					<?php echo vnnews_get_pagination_links_2($num_page); ?>
				<!-- END .pagination -->
				</div>

			<?php WP_Reset_Query(); ?>

			<!-- END .postarea full -->
			</div>

		<!-- END .sixteen columns -->
		</div>

	<?php endif; ?>

	<!-- END .row -->
	</div>

<!-- END .post class -->
</div>

<?php get_footer(); ?>